package com.mask.mr.number;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class NumJob {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);
        job.setMapperClass(NumberMapper.class);
        job.setReducerClass(NumReducer.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(LongWritable.class);
        FileInputFormat.setInputPaths(job,
                new Path("/Users/hx/Documents/massz.edu.cn/bigData/numbers/data.txt"));
        FileOutputFormat.setOutputPath(job,
                new Path("/Users/hx/Documents/massz.edu.cn/bigData/numbers/num"));
        boolean res = job.waitForCompletion(true);
        System.exit(res?0:1);
    }
}